package com.xiaoma.myaudience.biz.task;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.http.Header;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;

import android.content.Context;

import com.xiaoma.myaudience.biz.model.ActivityInfoModel;
import com.xiaoma.myaudience.biz.util.Constant;
import com.xiaoma.myaudience.util.HttpUtils;
import com.xiaoma.myaudience.util.Logger;
import com.xiaoma.myaudience.util.model.ModelUtils;
import com.xiaoma.myaudience.util.task.BaseDataAsyncTask;
import com.xiaoma.myaudience.util.task.BaseDataAsyncTask.DataAsyncCallback;

/**
 * 检查是否有软件是否有更新
 * 
 */
public class CheckUpdateTask extends BaseDataAsyncTask<Void, Void, Map<String, Object>>{
    private final static String TAG = "CheckUpdateTask ";
    
    public CheckUpdateTask(Context context, int taskType, DataAsyncCallback callback) {
        super(context, taskType, callback);
    }

	@Override
	protected Map<String, Object> doInBackground(Void... params) {
		String result = null;
		Map<String,Object> returnjson = null;
        try {            
        	List<NameValuePair> values = new ArrayList<NameValuePair>();
        	values.add(new BasicNameValuePair("type", "2"));
        	JSONObject jsonObject = HttpUtils.getHttpJSONObjectResult(getHttpClient(), 
        			Constant.URL_CHECKUPDATE_PATH, values, HttpUtils.GET);
        	if (jsonObject != null) {
        		returnjson = ModelUtils.json2Map(jsonObject);
        		result = (String) returnjson.get("code");
			}
        } catch (Exception e) {
            Logger.e(TAG, "doInBackground error!!!", e);
        } finally {
            closeHttpClient();
        }
        
        return returnjson;	
    }

}
